package kz.kstu.aecdemo.business.entity.security;

import kz.kstu.aecdemo.business.entity.CommonEntityConstant;
import kz.kstu.aecdemo.business.entity.Identifiable;

import javax.persistence.*;

/**
 * @author Filipp_Stankevich
 *         created: 27.09.11 19:48
 */
@NamedQueries({
        @NamedQuery(name = CommonEntityConstant.FIND_ACCOUNT_BY_LOGIN,
                query = "select a from AbstractAccount a where a.login = :login"),
        @NamedQuery(name = CommonEntityConstant.FIND_ALL_ACCOUNTS, query = "select a from AbstractAccount a")
})

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "ACCOUNT")
public abstract class AbstractAccount implements Identifiable {

    private Long id;
    private String login;
    private boolean isBlocked;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID")
    @Override
    public Long getId() {
        return id;
    }

    @Override
    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "LOGIN", unique = true, nullable = false)
    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    @Column(name = "IS_BLOCKED")
    public boolean isBlocked() {
        return isBlocked;
    }

    public void setBlocked(boolean blocked) {
        isBlocked = blocked;
    }
}
